#ifndef XML_H
#define XML_H

#include <QList>
#include <QStringList>
#include <QXmlStreamReader>

#include "xmlObj.h"
#include "xmlBlock.h"
#include "xmlLink.h"
#include "xmlNode.h"
#include "xmlDep.h"
#include "node.h"

class xml{

public:
   xml(QList<xmlBlock *> *blocks, QList<xmlLink *> *links,
QList<xmlNode *> *nodes);
   QList<xmlBlock *> * getBlockList();
   QList<xmlLink *> * getLinkList();
   QList<xmlNode *> * getNodeList();

   bool readFile(QString &fileName);


private:
   QList<xmlBlock *> * myBlockList;
   QList<xmlLink *> * myLinkList;
   QList<xmlNode *> * myNodeList;

   QXmlStreamReader reader;
   QStringList triggerTypeList;
   QStringList reactionTypeList;
   QStringList nodeTerminalsList;

   void readDesignElement();
   void readBlockElement();
   void readLinkElement();
   void readNodeElement();

   //block
   void readBlockID(xmlBlock *b);
   void readBlockTerm1ID(xmlBlock *b);
   void readBlockTerm2ID(xmlBlock *b);
   void readBlockState(xmlBlock *b);
   //void readTriggerID(xmlBlock *b);
   //void readTriggerType(xmlBlock *b);
   //void readReactionType(xmlBlock *b);
   void readBlockDep(xmlBlock *b);
   void readBlockCircleDep(xmlBlock *b);
   void readBlockFailedState(xmlBlock *b);
   void readBlockActiveState(xmlBlock *b);
   void readBlockStates(xmlBlock *b);
   void readBlockIdMergedDep(xmlBlock *b);
   void readBlockListIdMergedDep(xmlBlock *b);
   void readBlockIsNotRepairable(xmlBlock *b);
   void readBlockX(xmlBlock *b);
   void readBlockY(xmlBlock *b);

   //dip
   void readTriggerId(xmlDep *d);
   void readTriggerEvType(xmlDep *d);
   void readTriggerEvFinalStateId(xmlDep *d);
   void readReactionEvType(xmlDep *d);
   void readReactionEvFInalStateId(xmlDep *d);
   void readPropProbability(xmlDep *d);
   void readInitStates(xmlDep *d);
   void readCdfDip(xmlDep *d);
   QString readCdfType();
   void readParamKappa(cdfWeibull *w);
   void readParamLambda(cdfWeibull *w);
   void readParamA(cdfUniforme *u);
   void readParamB(cdfUniforme *u);
   void readParamAlfa(cdfErlang *e);
   void readParamErre(cdfErlang *e);

   void readDepIsLonely(xmlDep *d);
   void readLogicConditionalDep(xmlDep *d, xmlBlock *b);
   void readIdMyMergedDep(xmlDep *d);
   void readCircleX(xmlDep *d);
   void readPriority(xmlDep *d);
   void readCircleY(xmlDep *d);

   //link
   void readLinkID(xmlLink *l);
   void readLinkTerm1ID(xmlLink *l);
   void readLinkTerm2ID(xmlLink *l);

   //node
   void readNodeID(xmlNode *n);
   void readNodeNumTerm(xmlNode *n);
   void readNodeTerminals(xmlNode *n);
   void readNodeX(xmlNode *n);
   void readNodeY(xmlNode *n);

   //
   void skipUnknownElement();


};

#endif // XML_H
